from rest_framework.serializers import ModelSerializer
from rest_framework import serializers

from apps.goods.models import SPUSpecification, SpecificationOption


class SpecsModelSerializer(ModelSerializer):
    """规格选项信息"""
    spu_id = serializers.IntegerField()
    spu = serializers.StringRelatedField()

    class Meta:
        model = SPUSpecification
        fields = ['id', 'name', 'spu_id', 'spu']


class OptionsSerializer(ModelSerializer):
    """规格选项管理"""
    spec_id = serializers.IntegerField()
    spec = serializers.StringRelatedField()
    class Meta:
        model = SpecificationOption
        fields = "__all__"

